<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test</title>
        <style>
        :root {
            --primary-color: #4361ee;
            --secondary-color: #3f37c9;
            --text-color: #333;
            --light-bg: #f8f9fa;
            --card-bg: #ffffff;
            --border-color: #e9ecef;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: var(--light-bg);
            margin: 0;
            padding: 20px;
            color: var(--text-color);
        }

        .container {
            max-width: 1000px;
            margin: 0 auto;
        }

        .header {
            text-align: center;
            margin-bottom: 30px;
        }

        .header h1 {
            color: var(--primary-color);
            margin-bottom: 10px;
        }

        .date-selector {
            display: flex;
            justify-content: center;
            margin-bottom: 20px;
            gap: 10px;
        }

        .date-btn {
            padding: 8px 16px;
            background-color: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: 20px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .date-btn:hover {
            background-color: var(--primary-color);
            color: white;
        }

        .date-btn.active {
            background-color: var(--primary-color);
            color: white;
            border-color: var(--primary-color);
        }

        .hourly-forecast {
            display: flex;
            overflow-x: auto;
            padding: 20px 0;
            gap: 15px;
            scrollbar-width: thin;
            scrollbar-color: var(--primary-color) var(--light-bg);
        }

        .hourly-forecast::-webkit-scrollbar {
            height: 8px;
        }

        .hourly-forecast::-webkit-scrollbar-track {
            background: var(--light-bg);
            border-radius: 10px;
        }

        .hourly-forecast::-webkit-scrollbar-thumb {
            background-color: var(--primary-color);
            border-radius: 10px;
        }

        .hour-card {
            min-width: 120px;
            background-color: var(--card-bg);
            border-radius: 12px;
            padding: 15px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
            text-align: center;
            flex-shrink: 0;
            transition: transform 0.3s ease;
        }

        .hour-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
        }

        .hour-time {
            font-weight: bold;
            margin-bottom: 10px;
            font-size: 16px;
        }

        .weather-icon {
            width: 50px;
            height: 50px;
            margin: 5px auto;
        }

        .hour-temp {
            font-size: 20px;
            font-weight: bold;
            margin: 10px 0;
        }

        .hour-details {
            font-size: 12px;
            color: #666;
            margin-top: 5px;
        }

        .detail-row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 3px;
        }

        .detail-label {
            font-weight: bold;
        }

        .current-weather {
            background-color: var(--card-bg);
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 30px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .current-main {
            display: flex;
            align-items: center;
        }

        .current-temp {
            font-size: 48px;
            font-weight: bold;
            margin-right: 20px;
        }

        .current-details {
            text-align: right;
        }

        .current-description {
            font-size: 18px;
            margin-bottom: 5px;
        }

        @media (max-width: 768px) {
            .hour-card {
                min-width: 100px;
                padding: 12px;
            }

            .current-weather {
                flex-direction: column;
                text-align: center;
            }

            .current-main {
                margin-bottom: 15px;
                flex-direction: column;
            }

            .current-temp {
                margin-right: 0;
                margin-bottom: 10px;
            }

            .current-details {
                text-align: center;
            }
        }
    </style>
</head>
<body>
<div>
    {{data.daily}}
    {%set hourly_data = data.hourly | safe %}
</div>


<div>
      <div class="hourly-forecast" id="hourlyForecast">
            <!-- 这里将通过JavaScript动态生成每小时数据 -->
        </div>
</div>

<script>
        // 模拟每小时天气数据
        const hourlyData = {{hourly_data}}

        // 渲染每小时天气数据
        function renderHourlyForecast(data) {
            const container = document.getElementById('hourlyForecast');
            container.innerHTML = '';

            data.forEach(hour => {
                const card = document.createElement('div');
                card.className = 'hour-card';

                card.innerHTML = `
                    <div class="hour-time">${hour.dt}</div>
                    <img src="https://openweathermap.org/img/wn/${hour.weather[0].icon}@2x.png" alt="${hour.weather.description}" class="weather-icon">
                    <div class="hour-temp">${hour.temp}°C</div>
                    <div class="hour-details">
                        <div class="detail-row">
                            <span class="detail-label">湿度:</span>
                            <span>${hour.humidity}%</span>
                        </div>
                        <div class="detail-row">
                            <span class="detail-label">风速:</span>
                            <span>${hour.wind_speed} m/s</span>
                        </div>
                        <div class="detail-row">
                            <span class="detail-label">降水:</span>
                            <span>${hour.pop}%</span>
                        </div>
                    </div>
                `;

                container.appendChild(card);
            });
        }

        // 初始化
        document.addEventListener('DOMContentLoaded', () => {
            renderHourlyForecast(hourlyData);

            // 日期选择按钮事件
            const dateBtns = document.querySelectorAll('.date-btn');
            dateBtns.forEach(btn => {
                btn.addEventListener('click', () => {
                    dateBtns.forEach(b => b.classList.remove('active'));
                    btn.classList.add('active');
                    // 这里可以添加加载不同日期数据的逻辑
                });
            });
        });

    </script>
</body>
</html>